﻿using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using Budjelar.Model.Entities;

namespace Budjelar.Repository.EF.Configuration
{
    public class CenaArtiklaConfiguration : EntityTypeConfiguration<CenaArtikla>
    {
        public CenaArtiklaConfiguration()
        {
            ToTable("Cenovnik");
            HasKey(x => new { x.IdArtikla, x.IdProdavnice });
            Property(x => x.IdArtikla).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            Property(x => x.IdProdavnice).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            HasRequired(x => x.Artikal).WithMany().HasForeignKey(x => x.IdArtikla);
            HasRequired(x => x.Prodavnica).WithMany().HasForeignKey(x => x.IdProdavnice);
            Property(x => x.Cena).HasPrecision(8, 2);
        }
    }
}